<template>
    <div class="box">
        <header-tit img="orderT.png" tit="生意圈管理" />
        <el-form class="from">
            <el-radio style="margin-left:10px" v-model="filter.status" label="" >全部</el-radio>
            <el-radio  v-model="filter.status" label="PAYING" >待支付</el-radio>
            <el-radio v-model="filter.status" label="UNDO" >待上课</el-radio>
            <el-radio v-model="filter.status" label="DONE" >已上课</el-radio>
            <el-radio v-model="filter.status" label="REJECT" >拒绝上课</el-radio>
            <el-radio v-model="filter.status" label="CANCEL" >已取消</el-radio>
            <el-button class="btn" type="danger" @click="filter.offset = 0, querySchool()">确认</el-button>
            <el-form-item label="手机号搜索">
                <el-input class="fi" v-model="filter.mobile"></el-input>
            </el-form-item>
            <el-form-item label="订单编号">
                <el-input class="fi" v-model="filter.orderNo"></el-input>
            </el-form-item>
        </el-form>
        <div class="top">
            <div class="add">
                <el-button type="primary" @click="$router.push('bussinessDetail?')">新增</el-button>
            </div>
        </div>
        <el-table :data="tableData3" style="width: 100%">
            <el-table-column prop="master" label="发布者名称" width="180"></el-table-column>
            <el-table-column prop="publishAt" label="发布时间">
                <template slot-scope="scope" >
                    <div>{{scope.row.publishAt | formatDate}}</div>
                </template>
            </el-table-column>
            <el-table-column prop="content" label="内容"></el-table-column>
            <el-table-column prop="images" label="图片">
                <template slot-scope="scope">
                    <img class="img" :src="scope.row.adUrl" alt>
                </template>
            </el-table-column>
            <el-table-column prop="starCount" label="点赞数"></el-table-column>
            <el-table-column prop="reportStatus" label="举报状态"></el-table-column>
            <el-table-column prop="ID" label="操作">
                <template slot-scope="scope">
                    <el-button size="mini" @click="$router.push('bussinessDetail?id='+scope.row.id)">编辑</el-button>
                    <el-button size="mini" @click="deleteBussiness()">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="pat">
            <el-pagination v-if="count" background layout="prev, pager, next"  @current-change="currentPage" :page-size="filter.limit" :total="count"></el-pagination>
        </div>
    </div>
</template>
<script>
  import { Order } from "api"

  export default {
    data () {
      return {
        tableData3: [],
        filter: {
          offset: 0,
          limit: 10,
          status: "",
          orderNo: "",
          campusId: "",
          mobile: ""
        },
        ids: [],
        count: 0
      }
    },

    watch: {
      "filter.status" () {
        this.filter.offset = 0
        this.querySchool()
      }
    },

    created () {
      if (this.$store.state.Account.userInfo.right) {
        this.filter.campusId = this.$store.state.Account.userInfo.campusId
      }

      console.log(this.$store.state.Account.userInfo)
      this.querySchool()
    },

    methods: {
      async queryBussiness () {
        let res = await Order.querySchool(this.filter)
        this.tableData3 = res.data
        this.count = res.count
      },
      async deleteBussiness(id){
        await this.$confirm("确认要执行此操作吗")
        await BaseConfig.deleteNeed(id ? [id] : this.ids)
        this.queryNeed()
      },
      currentPage (e) {
        this.filter.offset = e * this.filter.limit - 1
        this.querySchool()
      },

      handleSelectionChange (e) {
        this.ids = e.map(item => item.id)
      },

    }
  }
</script>
<style lang="less" scoped>
    .box {
        padding-bottom: 100px;
    }
    .from {
        overflow: hidden;
        margin-top: 30px;
        .el-form-item {
            width: 233px;
            float: right;
        }
        .fi {
            width: 150px;
        }
        .btn {
            width: 100px;
            height: 40px;
            margin-right: 20px;
            float: right;
        }
    }
    .top {
        margin: 20px 0;
        background: white;
        overflow: hidden;
        .add {
            color: #656565;
            font-size: 15px;
            float: right;
            margin-right: 20px;
            div {
                float: left;
                margin-left: 15px;
            }
            span {
                margin: 0 5px;
            }
        }
    }
    .pat {
        margin-top: 40px;
        text-align: center;
    }
    .el-radio.is-bordered+.el-radio.is-bordered {
        margin: 0;
    }
    .el-radio {
        margin-top: 16px;
    }
</style>
